<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>append</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Geometry">
<link rel="up" href="../algorithms.html" title="Algorithms">
<link rel="prev" href="assign/assign_zero.html" title="assign_zero">
<link rel="next" href="azimuth.html" title="azimuth">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="assign/assign_zero.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../algorithms.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="azimuth.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="geometry.reference.algorithms.append"></a><a class="link" href="append.html" title="append">append</a>
</h4></div></div></div>
<p>
          <a class="indexterm" name="idm45246449290576"></a>
Appends one or more points to a linestring, ring, polygon, multi-geometry.
        </p>
<h6>
<a name="geometry.reference.algorithms.append.h0"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.synopsis"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.synopsis">Synopsis</a>
        </h6>
<p>
</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Geometry</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">RangeOrPoint</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">append</span><span class="special">(</span><span class="identifier">Geometry</span> <span class="special">&amp;</span> <span class="identifier">geometry</span><span class="special">,</span> <span class="identifier">RangeOrPoint</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">range_or_point</span><span class="special">,</span> <span class="identifier">signed_size_type</span> <span class="identifier">ring_index</span> <span class="special">=</span> <span class="special">-</span><span class="number">1</span><span class="special">,</span>
            <span class="identifier">signed_size_type</span> <span class="identifier">multi_index</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span></pre>
<p>
        </p>
<h6>
<a name="geometry.reference.algorithms.append.h1"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.parameters"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.parameters">Parameters</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Type
                  </p>
                </th>
<th>
                  <p>
                    Concept
                  </p>
                </th>
<th>
                  <p>
                    Name
                  </p>
                </th>
<th>
                  <p>
                    Description
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    Geometry &amp;
                  </p>
                </td>
<td>
                  <p>
                    Any type fulfilling a Geometry Concept
                  </p>
                </td>
<td>
                  <p>
                    geometry
                  </p>
                </td>
<td>
                  <p>
                    A model of the specified concept
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    RangeOrPoint const &amp;
                  </p>
                </td>
<td>
                  <p>
                    Either a range or a point, fullfilling Boost.Range concept or
                    Boost.Geometry Point Concept
                  </p>
                </td>
<td>
                  <p>
                    range_or_point
                  </p>
                </td>
<td>
                  <p>
                    The point or range to add
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    signed_size_type
                  </p>
                </td>
<td>
                </td>
<td>
                  <p>
                    ring_index
                  </p>
                </td>
<td>
                  <p>
                    The index of the ring in case of a polygon: exterior ring (-1,
                    the default) or interior ring index
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    signed_size_type
                  </p>
                </td>
<td>
                </td>
<td>
                  <p>
                    multi_index
                  </p>
                </td>
<td>
                  <p>
                    The index of the geometry to which the points are appended
                  </p>
                </td>
</tr>
</tbody>
</table></div>
<h6>
<a name="geometry.reference.algorithms.append.h2"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.header"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.header">Header</a>
        </h6>
<p>
          Either
        </p>
<p>
          <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
        </p>
<p>
          Or
        </p>
<p>
          <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">algorithms</span><span class="special">/</span><span class="identifier">append</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
        </p>
<h6>
<a name="geometry.reference.algorithms.append.h3"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.conformance"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.conformance">Conformance</a>
        </h6>
<p>
          The function append is not defined by OGC.
        </p>
<h6>
<a name="geometry.reference.algorithms.append.h4"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.supported_geometries"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.supported_geometries">Supported
          geometries</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                </th>
<th>
                  <p>
                    Point
                  </p>
                </th>
<th>
                  <p>
                    Range
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    Point
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Segment
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Box
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Linestring
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Ring
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Polygon
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    MultiPoint
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    MultiLinestring
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    MultiPolygon
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
<td>
                  <p>
                    <span class="inlinemediaobject"><img src="../../../img/ok.png" alt="ok"></span>
                  </p>
                </td>
</tr>
</tbody>
</table></div>
<h6>
<a name="geometry.reference.algorithms.append.h5"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.behavior"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.behavior">Behavior</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Case
                  </p>
                </th>
<th>
                  <p>
                    Behavior
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    Point, Box, Segment
                  </p>
                </td>
<td>
                  <p>
                    Compiles, but no action
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Linestring
                  </p>
                </td>
<td>
                  <p>
                    Appends point or range to the end of the linestring
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Ring
                  </p>
                </td>
<td>
                  <p>
                    Appends point or range to the end of the ring (without explicitly
                    closing it)
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Polygon
                  </p>
                </td>
<td>
                  <p>
                    Appends point or range to the end of the polygon (without explicitly
                    closing it), either the exterior ring (the default) or specify
                    a zero-based index for one of the interior rings. In the last
                    case, the interior rings are not resized automatically, so ensure
                    that the zero-based index is smaller than the number of interior
                    rings
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Multi Linestring
                  </p>
                </td>
<td>
                  <p>
                    Appends point or range to the end of the linestring with the
                    given multi index. The multi-linestring is not resized automatically,
                    so ensure that the multi index is smaller than then number of
                    linestring in the multi-linestring.
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Multi Polygon
                  </p>
                </td>
<td>
                  <p>
                    Appends point or range to the end of the polygon (without explicitly
                    closing it) with the given multi-index. The point or range is
                    appended at the end of the exterior ring (the default) or specify
                    a zero-based ring index for the interior rings. The multi-polygon
                    is not resized automatically, so ensure that the multi index
                    is smaller than then number of polygon in the multi-polygon.
                    The same applies for the interior rings of the polygon: the interior
                    rings are not resized automatically, so ensure that the zero-based
                    ring index is smaller than the number of interior rings of the
                    polygon.
                  </p>
                </td>
</tr>
</tbody>
</table></div>
<h6>
<a name="geometry.reference.algorithms.append.h6"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.complexity"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.complexity">Complexity</a>
        </h6>
<p>
          Linear
        </p>
<h6>
<a name="geometry.reference.algorithms.append.h7"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.example"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.example">Example</a>
        </h6>
<p>
          Shows usage of Boost.Geometry's append to append a point or a range to
          a polygon
        </p>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>

<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">boost_tuple</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">assign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> <a class="co" name="geometry.reference.algorithms.append.c0" href="append.html#geometry.reference.algorithms.append.c1"><img src="../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a>

<span class="identifier">BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS</span><span class="special">(</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">)</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
    <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">assign</span><span class="special">::</span><span class="identifier">tuple_list_of</span><span class="special">;</span>
    <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_tuple</span><span class="special">;</span>
    <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">append</span><span class="special">;</span>

    <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">tuple</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">polygon</span><span class="special">;</span>

    <span class="identifier">polygon</span> <span class="identifier">poly</span><span class="special">;</span>

    <span class="comment">// Append a range</span>
    <span class="identifier">append</span><span class="special">(</span><span class="identifier">poly</span><span class="special">,</span> <span class="identifier">tuple_list_of</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">)(</span><span class="number">0</span><span class="special">,</span> <span class="number">10</span><span class="special">)(</span><span class="number">11</span><span class="special">,</span> <span class="number">11</span><span class="special">)(</span><span class="number">10</span><span class="special">,</span> <span class="number">0</span><span class="special">));</span> <a class="co" name="geometry.reference.algorithms.append.c2" href="append.html#geometry.reference.algorithms.append.c3"><img src="../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a>
    <span class="comment">// Append a point (in this case the closing point)</span>
    <span class="identifier">append</span><span class="special">(</span><span class="identifier">poly</span><span class="special">,</span> <span class="identifier">make_tuple</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">));</span>

    <span class="comment">// Create an interior ring (append does not do this automatically)</span>
    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">interior_rings</span><span class="special">(</span><span class="identifier">poly</span><span class="special">).</span><span class="identifier">resize</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>

    <span class="comment">// Append a range to the interior ring</span>
    <span class="identifier">append</span><span class="special">(</span><span class="identifier">poly</span><span class="special">,</span> <span class="identifier">tuple_list_of</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">)(</span><span class="number">2</span><span class="special">,</span> <span class="number">5</span><span class="special">)(</span><span class="number">6</span><span class="special">,</span> <span class="number">6</span><span class="special">)(</span><span class="number">5</span><span class="special">,</span> <span class="number">2</span><span class="special">),</span> <span class="number">0</span><span class="special">);</span> <a class="co" name="geometry.reference.algorithms.append.c4" href="append.html#geometry.reference.algorithms.append.c5"><img src="../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a>
    <span class="comment">// Append a point to the first interior ring</span>
    <span class="identifier">append</span><span class="special">(</span><span class="identifier">poly</span><span class="special">,</span> <span class="identifier">make_tuple</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">),</span> <span class="number">0</span><span class="special">);</span>

    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">poly</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>

    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
        </p>
<div class="calloutlist"><table border="0" summary="Callout list">
<tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.algorithms.append.c1"></a><a href="#geometry.reference.algorithms.append.c0"><img src="../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td>
<td valign="top" align="left"><p>
              At the end to avoid conflicts with Boost.QVM
            </p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.algorithms.append.c3"></a><a href="#geometry.reference.algorithms.append.c2"><img src="../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td>
<td valign="top" align="left"><p>
              tuple_list_of delivers a range and can therefore be used in boost::geometry::append
            </p></td>
</tr>
<tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.algorithms.append.c5"></a><a href="#geometry.reference.algorithms.append.c4"><img src="../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td>
<td valign="top" align="left"><p>
              The last parameter ring_index 0 denotes the first interior ring
            </p></td>
</tr>
</table></div>
<p>
          Output:
        </p>
<pre class="programlisting">(((0, 0), (0, 10), (11, 11), (10, 0), (0, 0)), ((2, 2), (2, 5), (6, 6), (5, 2), (2, 2)))
</pre>
<h6>
<a name="geometry.reference.algorithms.append.h8"></a>
          <span class="phrase"><a name="geometry.reference.algorithms.append.see_also"></a></span><a class="link" href="append.html#geometry.reference.algorithms.append.see_also">See
          also</a>
        </h6>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
              <a class="link" href="assign/assign_points.html" title="assign_points">assign</a>
            </li></ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2021 Barend Gehrels,
      Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its affiliates<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="assign/assign_zero.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../algorithms.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="azimuth.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
